import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
// 重写了原型上的push方法，统一的处理了错误信息
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Pc',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/components/Home/index.vue')
  },
  {
    path: '/list',
    name: 'list',
    component: () => import('@/components/List/index.vue')
  },
  {
    path: '/detailed/:id/',
    name: 'detailed',
    component: () => import('@/components/Detailed/index.vue')
  },
  {
    path: '/life',
    name: 'life',
    component: () => import('@/components/Life/index.vue')
  },
  {
    path: '/essay',
    name: 'essay',
    component: () => import('@/components/Essay/index.vue')
  },
  {
    path: '/message',
    name: 'message',
    component: () => import('@/components/Message/index.vue')
  }
]

const router = new VueRouter({
  base: '/',
  mode: "hash",
  routes,
})

export default router
